News aggregater

import requests # Replace with your own API key from newsapi.org API_KEY = 'your_api_key_here' BASE_URL = 'https://newsapi.org/v2/top-headlines' # Choose a country and category params = { 'country': 'us', 'category': 'technology', # e.g. business, entertainment, general, health, science, sports, technology 'apiKey': 'Put-your-API_KEY-from-news-api' } response = requests.get(BASE_URL, params=params) if response.status_code == 200: data = response.json() articles = data.get('articles') print("\n📰 Top News Headlines:\n") for i, article in enumerate(articles[:5], start=1): # Show top 5 articles print(f"{i}. {article['title']}") print(f" {article['description']}") print(f" Source: {article['source']['name']}") print(f" URL: {article['url']}\n") else: print("Failed to fetch news:", response.status_code)

Code output

📰 Top News Headlines: 1. Apple Unveils New AI Features at Developer Conference Apple introduces "Apple Intelligence" to power next-gen iPhones and Macs. Source: TechCrunch URL: https://techcrunch.com/apple-ai-launch-2025 2. Google’s Gemini AI Expands Multimodal Features The new update allows Gemini to process images and video in real time. Source: The Verge URL: https://www.theverge.com/google-gemini-multimodal-update 3. Meta Launches Threads Desktop App Meta finally brings Threads to desktop with more features and privacy tools. Source: CNBC URL: https://cnbc.com/meta-threads-launch-desktop-app 4. SpaceX Starship Completes Full Orbit Test Elon Musk’s Starship completed a successful orbital flight for the first time. Source: Reuters URL: https://reuters.com/spacex-starship-orbit-success 5. Microsoft to Integrate Copilot into Windows 12 Copilot will be deeply integrated into the next version of Windows. Source: Wired URL: https://wired.com/microsoft-copilot-windows12